<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<link rel="stylesheet" type="text/css" href="../../css/reset.css"/>
		<link rel="stylesheet" type="text/css" href="../../css/add.css"/>
		<link rel="stylesheet" type="text/css" href="/layer_mod.css"/>
	</head>
	<body>
		<div id="app">
			<div class="header">
				<span>删除快递信息</span>
			</div>
			<div class="content">
				<table>	
					<tr>
						<td class="text-right">运单号</td><td class="content_right"><input class="input inline-input" placeholder="请输入运单号码" id="ex_num"> <span class="btn btn-info" id="search">立即查找</span></td>
					</tr>
				</table>
			</div>
			
			
			<div class="header">
				<span>查找信息如下</span>
			</div>
			<div class="content">
				<table>
					<tr>
						<td class="text-right">快递单号</td><td class="content_right"><input class="input"></td>
					</tr>
					<tr>
						<td class="text-right">快递公司</td><td class="content_right"><input class="input"></td>
					</tr>
					<tr>
						<td class="text-right">收货人姓名</td><td class="content_right"><input class="input"></td>
					</tr>
					<tr>
						<td class="text-right">手机号码</td><td class="content_right"><input class="input"></td>
					</tr>
					<tr>
						<td class="text-right">快递状态</td><td class="content_right"><span id="status"></span></td>
					</tr>
					<tr>
						<td></td><td class="content_right"><span class="btn btn-info" id="delete">立即删除</span></td>
					</tr>
				</table>
			</div>
		</div>
	</body>
	<script src="/js/jquery-2.1.4.min.js"></script>
	<script src="/js/layer/layer.js"></script>
	<script src="/admin/ckeckAllInputs.js"></script>
	<script>
		// 在进行查询前隐藏页面上的快递信息部分
		$(".header:eq(1),.content:eq(1)").hide();
		// 存储查询到的快递的id，用于删除快递
		var expressID = null;
		$(function () {
			$("#search").click(function () {
				var ex_num = $("#ex_num").val();
				if (ifExNumChecked(ex_num)) {
					var windowID = layer.load(2);
					$.getJSON("/express/search.do",{ex_num:ex_num},function (data) {
						layer.close(windowID);
						layer.msg(data.result);
						if (data.status == 0) {
							// 以淡入效果在1s内显示出页面上隐藏的快递信息
							// 以 http://localhost:8080/express/search.do?ex_num=124 查找到的data信息格式
							// {"status":0,"result":"查询成功","data":{"id":2,"ex_num":"124","username":"张三","userphone":"13843838438","company":"京东快递","code":"213456","intime":"Feb 28, 2021, 11:43:03 AM","status":0,"staffphone":"18888888888"}}
							$(".header:eq(1),.content:eq(1)").fadeIn(1000);
							expressID = data.data.id;
							$("input:eq(1)").val(data.data.ex_num);
							$("input:eq(2)").val(data.data.company);
							$("input:eq(3)").val(data.data.username);
							$("input:eq(4)").val(data.data.userphone);
							// 在删除页面，查找到的信息不能进行修改操作，将输入框disable
							$("input:eq(1),input:eq(2),input:eq(3),input:eq(4)").prop("disabled",true);
							if (data.data.status == 0) {
								// 未签收
								$("#status").html("未签收");
							} else {
								// 已签收
								$("#status").html("已签收");
							}
						}
					});
				}
			});
			$("#delete").click(function () {
				if (expressID==null) {
					layer.alert("无快递信息，无法进行删除，请先进行查询！",{icon:2,shade:0.05})
				} else {
					layer.confirm("您确定要删除该快递吗？", {icon:3, btn: ["确定", "取消"], title: "提示"}, function (index) {
						layer.close(index);
						var windowID = layer.load(2);
						$.getJSON("/express/delete.do",{id:expressID},function (data) {
							layer.close(windowID);
							layer.msg(data.result);
							if (data.status==0){
								$(".header:eq(1),.content:eq(1)").hide();
							}
						});
					});
				}
			});
		});
	</script>
</html>
